<include file="public@header"/>
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('code/codeadd')}">二维码添加</a></li>
    </ul>
        <div class="row">
            <div class="col-md-9">
                <table class="table table-bordered">
                    <tr>
                        <th><b>请输入二维码名称 </b><b style="color: red;">* 目前不支持中文，若中文无法生成！</b></th>
                    </tr>
                    <tr>
                        <td>
                            <input class="form-control namme" type="text" name=""
                                   id="title" required value="" placeholder="请输入名称"/>
                        </td>
                    </tr>
                    <tr>
                        <th><b>请输入二维码描述 </b></th>
                    </tr>
                    <tr>
                        <td>
                            <input class="form-control dess" type="text" name=""
                                    required value="" placeholder="请输入描述"/>
                        </td>
                    </tr>
                    <tr>
                        <th><b>请输入二维码地址 </b><b style="color: red;">* 没有可不写，请添加网页前缀</b></th>
                    </tr>
                    <tr>
                        <td>
                            <input class="form-control urll" type="url" name=""
                                   required value="" placeholder="请输入二维码地址"/>
                        </td>
                    </tr>
                    <tr>
                        <th><b>二维码图 </b><b style="color: green">* 鼠标点击右键保存</b></th>
                    </tr>
                    <tr>
                        <td>
                            <div style="text-align: center;">
                                <img class="qrcode2" src="__TMPL__/public/assets/images/default-thumbnail.png"
                                     id="thumbnail-preview"
                                     width="135" style="cursor: pointer"/>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th><b>添加时间</b></th>
                    </tr>
                    <tr>
                        <td>
                            <input class="form-control js-bootstrap-datetime" type="text" name="post[published_time]"
                                   value="{:date('Y-m-d H:i:s',time())}">
                        </td>
                    </tr>
                </table>
                <div class="form-group">
                    <div class="col-sm-offset-5 col-sm-10">
                        <audio class="mpp3" controls="controls">
                            <source src="__TMPL__/public/6480.mp3"/>
                        </audio>
                        <button type="button" style="width: 10vw;display: none;" class="btn btn-success subb">确定提交</button>
                    </div>
                </div>
            </div>
        </div>
</div>
    <script>
        $('.namme').bind(' input propertychange ',function(){
            var lenss = $.trim($('.namme').val());
            if(lenss != ''){
                $('.subb').show();
            }else {
                $('.subb').hide();
            }
        } );

        $('.mpp3').hide();

        $('.subb').click(function () {
            var textname = $('.namme').val();
            var textdes = $('.dess').val();
            var texturl = $('.urll').val();
            $('.subb').text('提交中......');
            console.log(textname);
            $.ajax({
                url:'/mainiu/code/add',
                type:"post",
                data:{
                    name:textname,
                    des:textdes,
                    url:texturl
                },
                success:function(data){
                    $('.subb').text('确定提交');
                    var ress= $.parseJSON(data);
                    if(ress.sta==1){
                        $('.qrcode2').attr("src",ress.codethumb);
                        $('.mpp3')[0].play();
                    }else {
                        alert(ress);
                    }
                },
                error:function(e){
                    alert('失败');
                }
            });
        });
    </script>
</body>
</html>
